package com.ruoyi.healthCard.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.healthCard.domain.TBizPackage;
import com.ruoyi.healthCard.service.ITBizPackageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 套餐Controller
 * 
 * @author ruoyi
 * @date 2025-06-20
 */
@RestController
@RequestMapping("/health/package")
public class TBizPackageController extends BaseController
{
    @Autowired
    private ITBizPackageService tBizPackageService;

    /**
     * 查询套餐列表
     */
    @PreAuthorize("@ss.hasPermi('health:package:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBizPackage tBizPackage)
    {
        startPage();
        List<TBizPackage> list = tBizPackageService.selectTBizPackageList(tBizPackage);
        return getDataTable(list);
    }

    /**
     * 导出套餐列表
     */
    @PreAuthorize("@ss.hasPermi('health:package:export')")
    @Log(title = "套餐", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBizPackage tBizPackage)
    {
        List<TBizPackage> list = tBizPackageService.selectTBizPackageList(tBizPackage);
        ExcelUtil<TBizPackage> util = new ExcelUtil<TBizPackage>(TBizPackage.class);
        util.exportExcel(response, list, "套餐数据");
    }

    /**
     * 获取套餐详细信息
     */
    @PreAuthorize("@ss.hasPermi('health:package:query')")
    @GetMapping(value = "/{packageId}")
    public AjaxResult getInfo(@PathVariable("packageId") Long packageId)
    {
        return success(tBizPackageService.selectTBizPackageByPackageId(packageId));
    }

    /**
     * 新增套餐
     */
    @PreAuthorize("@ss.hasPermi('health:package:add')")
    @Log(title = "套餐", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBizPackage tBizPackage)
    {
        return toAjax(tBizPackageService.insertTBizPackage(tBizPackage));
    }

    /**
     * 修改套餐
     */
    @PreAuthorize("@ss.hasPermi('health:package:edit')")
    @Log(title = "套餐", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBizPackage tBizPackage)
    {
        return toAjax(tBizPackageService.updateTBizPackage(tBizPackage));
    }

    /**
     * 删除套餐
     */
    @PreAuthorize("@ss.hasPermi('health:package:remove')")
    @Log(title = "套餐", businessType = BusinessType.DELETE)
	@DeleteMapping("/{packageIds}")
    public AjaxResult remove(@PathVariable Long[] packageIds)
    {
        return toAjax(tBizPackageService.deleteTBizPackageByPackageIds(packageIds));
    }
}
